#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);

    QObject::connect(ui->radioButton_red, SIGNAL(clicked()), this, SLOT(on_radioBox_color_clicked()));
    QObject::connect(ui->radioButton_blue, SIGNAL(clicked()), this, SLOT(on_radioBox_color_clicked()));
    QObject::connect(ui->radioButton_default, SIGNAL(clicked()), this, SLOT(on_radioBox_color_clicked()));

}

Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_checkBox_underline_clicked(bool checked)
{
    QFont font = ui->textEdit->font();
    font.setUnderline(checked);
    ui->textEdit->setFont(font);
}

void Dialog::setPlainTextEditorColor(QPlainTextEdit* te, QColor color){
    QPalette pale =  te->palette();
    pale.setColor(QPalette::Text, color);
    te->setPalette(pale);
}

void Dialog::on_radioBox_color_clicked()
{
    if(ui->radioButton_red->isChecked()){
        setPlainTextEditorColor(ui->textEdit, Qt::red);
    }else if(ui->radioButton_blue->isChecked()){
        setPlainTextEditorColor(ui->textEdit, Qt::blue);
    }else{
        setPlainTextEditorColor(ui->textEdit, Qt::black);
    }
}

void Dialog::on_checkBox_iter_clicked(bool checked)
{

}
